package com.maoye.ossp.sys.base.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.hotent.base.api.query.QueryFilter;
import com.maoye.ossp.common.entity.Page;
import com.maoye.ossp.common.web.BaseController;
import com.maoye.ossp.sys.base.entity.SysBaseCountry;
import com.maoye.ossp.sys.base.entity.SysBaseFloor;
import com.maoye.ossp.sys.base.entity.SysBaseFormat;
import com.maoye.ossp.sys.base.entity.SysBaseRegion;
import com.maoye.ossp.sys.base.entity.SysBaseShop;
import com.maoye.ossp.sys.base.entity.SysBaseShopFormat;
import com.maoye.ossp.sys.base.entity.SysBaseStorageLocation;
import com.maoye.ossp.sys.base.service.SysBaseCountryService;
import com.maoye.ossp.sys.base.service.SysBaseFloorService;
import com.maoye.ossp.sys.base.service.SysBaseFormatService;
import com.maoye.ossp.sys.base.service.SysBaseRegionService;
import com.maoye.ossp.sys.base.service.SysBaseShopService;
import com.maoye.ossp.sys.site.utils.BeanToMap;
/**
 * 区域门店楼层controller类
 * @author liangtao
 * @date   2014-4-17
 */
@Controller
@RequestMapping(value = "sys/base/regionShopFloor/")
public class SysBaseRegionShopFloorController extends BaseController{
	@Resource
	private SysBaseRegionService sysBaseRegionService ;
	@Resource
	private SysBaseShopService sysBaseShopService ;
	@Resource
	private SysBaseFloorService sysBaseFloorService ;
	
	@Resource
	private SysBaseCountryService sysBaseCountryService;
	@Resource
	private SysBaseFormatService  sysBaseFormatService;
	/**
	 * 获得区域列表
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	
	@RequestMapping(value = "getRegionList")
	public String getRegionList(HttpServletRequest request, HttpServletResponse response,Model model,SysBaseRegion region) {
		QueryFilter queryFilter = getQuerFilter(request,region);
		Page<SysBaseRegion> page = (Page<SysBaseRegion>)sysBaseRegionService
				.find(queryFilter);
		Map map=new HashMap();
		List<SysBaseRegion> list =page.getList();
		for(int i=0;i<list.size();i++){
			if(list.get(i).getParent()!=null&&!list.get(i).getParent().equals("")){
			   map.put("id",list.get(i).getParent());
			   list.get(i).setParentArea(sysBaseRegionService.getParentRegionById(map).getName());
			}else{
			list.get(i).setParentArea("无");
			}
			if(sysBaseRegionService.checkIsParent(list.get(i).getCode())){
				//父节点
				list.get(i).setFlag("0"); 
			}else{
				//叶子节点
				list.get(i).setFlag("1"); 
			}
		} 
		page.setList(list);
		model.addAttribute("page", page);
		model.addAttribute("sysBaseRegion",region);
		return resultPage("/sys/base/region/getRegionList", model, request);
	}
	/**
	 * 获得门店列表
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	@RequestMapping(value = "getShopList")
	public String getShopList(HttpServletRequest request, HttpServletResponse response,Model model,SysBaseShop shop) {
		QueryFilter queryFilter = getQuerFilter(request,shop);
		Page<SysBaseShop> page = (Page<SysBaseShop>)sysBaseShopService
				.find(queryFilter);
		List<SysBaseShop>list =page.getList();
		Map<String, Object> map = new HashMap<String, Object>();
		/*List<SysBaseShop>list = sysBaseShopService.getShopList(BeanToMap.beanToMap(shop));*/
		for(int i=0;i<list.size();i++){	
			map.put("code",list.get(i).getRegionCode());
			list.get(i).setRegionArea(sysBaseShopService.getRegionNameByShopId(map));
		} 
		page.setList(list);
		SysBaseShop sysBaseShop=new SysBaseShop();
		model.addAttribute("sysBaseShop",sysBaseShop);
		model.addAttribute("page", page);
		return resultPage("/sys/base/shop/getShopList", model, request);
	}
	
	
	
	/**
	 * 获得楼层列表
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	@RequestMapping(value = "getFloorList")
	public String getFloorList(HttpServletRequest request, HttpServletResponse response,Model model,SysBaseFloor floor) {
		QueryFilter queryFilter = getQuerFilter(request,floor);
		Page<SysBaseFloor> page = (Page<SysBaseFloor>)sysBaseFloorService
				.find(queryFilter);
		Map<String, Object> map = new HashMap<String, Object>();
		List<SysBaseFloor>list=page.getList();
		for(int i=0;i<list.size();i++){	
			map.put("code",list.get(i).getParent());
			SysBaseShop shop =sysBaseShopService.getShopById(map);
			if(shop!=null){
			   list.get(i).setParentArea(shop.getName());
			}else{
				list.get(i).setParentArea("无");
			}
		} 
		SysBaseFloor sysBaseFloor=new SysBaseFloor();
		model.addAttribute("sysBaseFloor",sysBaseFloor);
		model.addAttribute("page", page);
		return resultPage("/sys/base/floor/getFloorList", model, request);
	}
	
	/**
	 * 加载区域根节点
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	@RequestMapping(value ="getzNodes")
	public void getzNodes(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setCharacterEncoding("utf-8");
		String contextPath=request.getContextPath();
		PrintWriter out = response.getWriter();
		StringBuffer json = new StringBuffer();
		Map map = new HashMap();
		List<SysBaseRegion>Regions = sysBaseRegionService.getRootRegion(map);
			json.append("[");
			for(int i = 0; i < Regions.size(); i++){
				SysBaseRegion Region = Regions.get(i);
				Long pid = null;
					//pid = 0L;				
					json.append("{").append("id:").append(Region.getCode()).append(",");
					json.append("pId:").append(Region.getParent()).append(",");
					json.append("name:\"").append(Region.getName()).append("\"").append(",");
					if(sysBaseRegionService.checkIsParent(Region.getCode())){
						json.append("isParent:").append(1);  
					}else{
						json.append("isParent:").append(0);
					}
					json.append(",");
					json.append("open:").append("false"); 
					json.append("}");
					if(i < Regions.size()-1){
						json.append(",");
					}
			}
		json.append("]");
		out.print(json.toString());
		out.flush();
		out.close();		
	}
	/**
	 * 根据区域Id加载门店信息
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	@RequestMapping(value ="getShopsByPId")
	public void  getShopsByPId (HttpServletRequest request, HttpServletResponse response) throws IOException{
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		String contextPath=request.getContextPath();
		String pId=request.getParameter("treeId");
		StringBuilder json = new StringBuilder();
		Map map = new HashMap();
		map.put("pid", pId);
		List<SysBaseShop>shops = sysBaseShopService.getShopsByPId(map);
		json.append("[");
		for(int i = 0;i<shops.size();i++){
			SysBaseShop shop = shops.get(i);
			json.append("{").append("id:").append(shop.getNo()).append(",");
			json.append("pId:").append(shop.getRegionCode()).append(",");
			json.append("name:\"").append(shop.getName()).append("\"");//.append(",");
			json.append("}");
			if(i < shops.size()-1){
				json.append(",");
			}		
		}
		json.append("]");
		/*model.addAttribute("shopsList",shopsList);
		return "/sys/base/shop/shopTree";*/
		out.print(json.toString());
		out.flush();
		out.close();
	}
	/**
	 * 根据门店Id加载楼层信息
	 * @param request
	 * @param responser
	 * @throws IOException
	 */
	@RequestMapping(value ="getFloorByPId")
	public void  getFloorByPId (HttpServletRequest request, HttpServletResponse response) throws IOException{
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		String pId=request.getParameter("pId");
		StringBuilder json = new StringBuilder();
		Map map = new HashMap();
		map.put("pid", pId);
		List<SysBaseFloor>floors = sysBaseFloorService.getFloorByPId(map);
		json.append("[");
		for(int i = 0;i<floors.size();i++){
			SysBaseFloor floor = floors.get(i);
			json.append("{").append("id:").append(floor.getCode()).append(",");
			json.append("pId:").append(floor.getParent()).append(",");
			json.append("name:\"").append(floor.getName()).append("\"").append(",");
			json.append("}");
			if(i < floors.size()-1){
				json.append(",");
			}		
		}
		json.append("]");
		out.print(json.toString());
		out.flush();
		out.close();
	} 

	
	/**
	 * 根据父节点加载子节点
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	@RequestMapping(value = "regionChild")
	public void ChildlistByPId(HttpServletRequest request, HttpServletResponse response ) throws IOException {	
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		String contextPath=request.getContextPath();
		String pId=request.getParameter("treeNodeId");
		StringBuilder json = new StringBuilder();
		Map map = new HashMap();
		map.put("pid", pId);
		List<SysBaseRegion>Regions = sysBaseRegionService.ChildlistByPId(map);
		json.append("[");
		for(int i = 0;i<Regions.size();i++){
			SysBaseRegion Region = Regions.get(i);
			json.append("{").append("id:").append(Region.getCode()).append(",");
			json.append("pId:").append(pId).append(",");
			json.append("name:\"").append(Region.getName()).append("\"").append(",");
			if(sysBaseRegionService.checkIsParent(Region.getCode())){
				json.append("isParent:").append(1);  
			}else{
				json.append("isParent:").append(0);
			}
			json.append(",");
			json.append("open:").append("true"); 
			json.append("}");
			if(i < Regions.size()-1){
				json.append(",");
			}		
		}
		json.append("]");
		out.print(json.toString());
		out.flush();
		out.close();
	}
	
	/**
	 * 增加区域信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value = "addRegion")
	public String addRegion(HttpServletRequest request,Model model) throws IOException {
		Map map = new HashMap();
		SysBaseRegion sysBaseRegion=new SysBaseRegion();
		model.addAttribute("sysBaseRegion",sysBaseRegion);
		return "/sys/base/region/add";

	}	
	/**
	 * 验证区域编码
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value = "checkRegionCode")
	public void checkRegionCode(HttpServletRequest request, HttpServletResponse response) throws IOException{
		Map map = new HashMap();
		String code = request.getParameter("code");	
		map.put("code",code);
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject();
		if(sysBaseRegionService.checkRegionCode(map)){
			json.put("resCode",0); //区域号可用
		}else{
			json.put("resCode",1);//区域号不可以用
		}
		out.print(json.toString());
		out.flush();
		out.close();
	}
	/**
	 * 保存区域信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value = "saveRegion")
	public String saveRegion(SysBaseRegion region,HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes) throws IOException{
		region.setId(idGenerator.getUId());
		region.setCode(region.getCode().replaceAll(",","").toString());
		region.setParent(region.getParent().replaceAll(",","").toString());
		//设置创建人
		region.setCreatBy("");
		sysBaseRegionService.saveRegion(region);
		addMessage(redirectAttributes, "保存成功");
		return "redirect:getRegionList";
	}
	
	
	/**
	 * 查看区域信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value ="viewRegion")
	public String viewRegion(HttpServletRequest request, HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String parentArea =request.getParameter("parentArea");
		Map map = new HashMap();
		map.put("id",code);
		SysBaseRegion sysBaseRegion=null;
		sysBaseRegion=sysBaseRegionService.getParentRegionById(map);
		SysBaseCountry sysBaseCountry=new SysBaseCountry();
		map.put("code",sysBaseRegion.getCountryCode());
		sysBaseCountry=sysBaseCountryService.getCountrybyCode(map);
		model.addAttribute("sysBaseRegion",sysBaseRegion);
		model.addAttribute("parentArea",parentArea);
		if(sysBaseCountry!=null){
			model.addAttribute("countryName",sysBaseCountry.getName());
		}
		return "/sys/base/region/view";
	}
	
	
	
	/**
	 * 删除区域信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value ="removeRegion")
	public String removeRegion(HttpServletRequest request, HttpServletResponse response,RedirectAttributes redirectAttributes){
		Map map = new HashMap();
		String code = request.getParameter("code");
		map.put("code", code);
		sysBaseRegionService.removeRegion(map);
		addMessage(redirectAttributes, "删除成功");
		return "redirect:getRegionList";
	} 
	/**
	 * 更新区域信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value ="updateRegion")
	public String updateRegion(HttpServletRequest request, HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String parentArea =request.getParameter("parentArea");
		Map map = new HashMap();
		map.put("id",code);
		SysBaseRegion sysBaseRegion=null;
		sysBaseRegion=sysBaseRegionService.getParentRegionById(map);
		SysBaseCountry sysBaseCountry=new SysBaseCountry();
		map.put("code",sysBaseRegion.getCountryCode());
		sysBaseCountry=sysBaseCountryService.getCountrybyCode(map);
		model.addAttribute("sysBaseRegion",sysBaseRegion);
		model.addAttribute("parentArea",parentArea);
		if(sysBaseCountry!=null){
			model.addAttribute("countryName",sysBaseCountry.getName());
		}
		return "/sys/base/region/update";
	}
	@RequestMapping(value ="saveUpdateRegion")
    public String saveUpdateRegion(SysBaseRegion region,HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
        //设置修改人
		region.setCode(region.getCode().replaceAll(",","").toString());
		region.setParent(region.getParent().replaceAll(",","").toString());
		region.setUpdateBy("");
		sysBaseRegionService.savaUpdateRegion(region);
		addMessage(redirectAttributes, "修改成功");
		return "redirect:getRegionList";
    }
	@RequestMapping(value ="addShop")
	public String addShop(HttpServletRequest request, HttpServletResponse response,Model model){
		String regionCode =request.getParameter("treeid");
		String regionName=request.getParameter("name");
		SysBaseShop sysBaseShop=new SysBaseShop();
		sysBaseShop.setRegionCode(regionCode);
		model.addAttribute("sysBaseShop",sysBaseShop);
		model.addAttribute("regionName",regionName);
		return "/sys/base/shop/add"; 
	}
	@RequestMapping(value ="checkShopCode")
	public void checkShopCode(HttpServletRequest request,HttpServletResponse response) throws IOException{
		Map map = new HashMap();
		String code = request.getParameter("code");	
		map.put("code",code);
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject();
		if(sysBaseShopService.checkShopCode(map)){
			json.put("resCode",0); //门店号可用
		}else{
			json.put("resCode",1);//门店号不可以用
		}
		out.print(json.toString());
		out.flush();
		out.close();
	}
	@RequestMapping(value ="saveShop")
	public String  saveShop(SysBaseShop shop,HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes) throws IOException{
		shop.setId(idGenerator.getUId());
		shop.setNo(shop.getNo().replaceAll(",","").toString());
		shop.setRegionCode(shop.getRegionCode().replaceAll(",","").toString());
		String formatsCode=shop.getFormatCode();
		String []formatCode=formatsCode.split(";");
		SysBaseShopFormat  sysBaseShopFormat=new SysBaseShopFormat();
		sysBaseShopFormat.setShopCode(shop.getNo());
		if(formatCode!=null){
		  for(int i=0;i<formatCode.length;i++){
			  sysBaseShopFormat.setId(idGenerator.getUId());
			  sysBaseShopFormat.setFormatCode(formatCode[i].toString());
			  sysBaseFormatService.saveShopFormatRelation(sysBaseShopFormat);
		  }
		}
		//设置创建人
		shop.setCreateBy("");
		sysBaseShopService.saveShop(shop);
		addMessage(redirectAttributes, "保存成功");
		return "redirect:getShopList";
	}
	/**
	 * 查看门店信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value ="viewShop")
	public String viewShop(HttpServletRequest request, HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String parentArea =request.getParameter("parentArea");
		Map map = new HashMap();
		map.put("code",code);
		SysBaseShop sysBaseShop=null;
		sysBaseShop=sysBaseShopService.getShopById(map);
		if(sysBaseShop!=null){
			//添加父区域
			sysBaseShop.setRegionArea(parentArea);
			List<SysBaseFormat>list=sysBaseFormatService.getShopFormatRelationList(map);
			String formatsName="";
			if(list!=null){
				for(int i=0;i<list.size();i++){
					formatsName=formatsName+list.get(i).getName();
					if(i<list.size()-1){
						formatsName=formatsName+";";
					}
				}
			}
			sysBaseShop.setFormatName(formatsName);
			model.addAttribute("shop",sysBaseShop);
		}
		return "/sys/base/shop/view";
	}
	@RequestMapping(value ="updateShop")
	public String updateShop(HttpServletRequest request,HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String regionArea =request.getParameter("parentArea");
		SysBaseShop shop=null;
		Map map = new HashMap();
		map.put("code",code);
		shop = sysBaseShopService.getShopById(map);
		String cityName=shop.getCityName();
		String formatCode="";
		String formatName="";
		//regionArea=sysBaseShopService.getRegionNameByShopId(map);
		List<SysBaseFormat>list=sysBaseFormatService.getShopFormatRelationList(map);
		for(int i=0;i<list.size();i++){
			formatCode=formatCode+list.get(i).getCode();
			formatName=formatName+list.get(i).getName();
			if(i<list.size()-1){
				formatCode=formatCode+";";
				formatName=formatName+";";
			}
		}
		shop.setFormatCode(formatCode);
		if(formatName!=null){
			model.addAttribute("formatName",formatName);
		}
		if(regionArea!=null){
			model.addAttribute("regionArea",regionArea);
		}
		if(cityName!=null){
			model.addAttribute("cityName",cityName);
		}
		model.addAttribute("sysBaseShop",shop);
		return "/sys/base/shop/update";
	}
	@RequestMapping(value ="saveUpdateShop")
	public String saveUpdateShop(HttpServletRequest request,HttpServletResponse response,SysBaseShop shop ,RedirectAttributes redirectAttributes){
		shop.setId(idGenerator.getUId());
		//设置修改人
		shop.setUpdateBy("");
		Map map=new HashMap();
		map.put("shopCode",shop.getNo());
		sysBaseFormatService.removeShopFormatRelationByShopCode(map);
		String formatsCode=shop.getFormatCode();
		String []formatCode=formatsCode.split(";");
		SysBaseShopFormat  sysBaseShopFormat=new SysBaseShopFormat();
		sysBaseShopFormat.setShopCode(shop.getNo());
		if(formatCode!=null){
		  for(int i=0;i<formatCode.length;i++){
			  sysBaseShopFormat.setId(idGenerator.getUId());
			  sysBaseShopFormat.setFormatCode(formatCode[i].toString());
			  sysBaseFormatService.saveShopFormatRelation(sysBaseShopFormat);
		  }
		}
		
		sysBaseShopService.saveUpdateShop(shop);
		addMessage(redirectAttributes, "修改成功");
		return "redirect:getShopList";
	}
	@RequestMapping(value ="deleteShop")
	public String deleteShop(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		String code =request.getParameter("code");
		Map map = new HashMap();
		map.put("code",code);
		map.put("shopCode",code);
		sysBaseFormatService.removeShopFormatRelationByShopCode(map);
		sysBaseShopService.deleteShop(map);
		addMessage(redirectAttributes, "删除成功");
		return "redirect:getShopList";
	}
	@RequestMapping(value ="addFloor")
	public String addFloor(HttpServletRequest request,HttpServletResponse response,Model model){	
		SysBaseFloor sysBaseFloor=new SysBaseFloor();
		model.addAttribute("sysBaseFloor",sysBaseFloor);
		return "/sys/base/floor/add"; 
	}
	
	@RequestMapping(value ="checkFloorCode")
	public void checkFloorCode(HttpServletRequest request,HttpServletResponse response) throws IOException{
		Map map = new HashMap();
		String code = request.getParameter("code");	
		String shopCode=request.getParameter("shopCode");
		map.put("code",code);
		map.put("shopCode",shopCode);
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject();
		if(sysBaseFloorService.checkFloorCode(map)){
			json.put("resCode",0); //门店号可用
		}else{
			json.put("resCode",1);//门店号不可以用
		}
		out.print(json.toString());
		out.flush();
		out.close();
	}
	@RequestMapping(value ="saveFloor")
	public String saveFloor(SysBaseFloor floor,HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes) throws IOException{
		floor.setId(idGenerator.getUId());
		//设置创建人
		floor.setCreateBy("");
		sysBaseFloorService.saveFloor(floor);
		addMessage(redirectAttributes, "保存成功");
		return "redirect:getFloorList";
	}
	
	/**
	 * 查看门店信息
	 * @param region
	 * @param model
	 * @param request
	 * @return
	 * @throws IOException 
	 * @throws ServletException 
	 */
	@RequestMapping(value ="viewFloor")
	public String viewFloor(HttpServletRequest request, HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String shopCode =request.getParameter("shopCode");
		String shopName =request.getParameter("shopName");
		Map map = new HashMap();
		map.put("code",code);
		map.put("shopCode",shopCode);
		SysBaseFloor sysBaseFloor=null;
		sysBaseFloor=sysBaseFloorService.getFloorById(map);
		if(sysBaseFloor!=null){
			//添加门店名称
			sysBaseFloor.setParentArea(shopName);
			model.addAttribute("floor",sysBaseFloor);
		}
		return "/sys/base/floor/view";
	}
	
	@RequestMapping(value ="updateFloor")
	public String updateFloor(HttpServletRequest request,HttpServletResponse response,Model model){
		String code =request.getParameter("code");
		String shopCode =request.getParameter("shopCode");
		String shopName =request.getParameter("shopName");
		Map map = new HashMap();
		map.put("code",code);
		map.put("shopCode",shopCode);
		SysBaseFloor sysBaseFloor=null;
		sysBaseFloor=sysBaseFloorService.getFloorById(map);
		if(sysBaseFloor!=null){
			//添加门店名称
			sysBaseFloor.setParentArea(shopName);
			model.addAttribute("cityName",sysBaseFloor.getCityName());
			model.addAttribute("shopName",sysBaseFloor.getParentArea());
			model.addAttribute("sysBaseFloor",sysBaseFloor);
		}
		return "/sys/base/floor/update";
	}
	
	@RequestMapping(value ="saveUpdateFloor")
	public String saveUpdateFloor(HttpServletRequest request,HttpServletResponse response,SysBaseFloor floor,RedirectAttributes redirectAttributes){
		floor.setId(idGenerator.getUId());
		//设置修改人
		floor.setUpdateBy("");
		sysBaseFloorService.saveUpdateFloor(floor);
		addMessage(redirectAttributes, "修改成功");
		return "redirect:getFloorList";
	}
	@RequestMapping(value ="deleteFloor")
	public String deleteFloor(HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes){
		String code =request.getParameter("code");
		Map map = new HashMap();
		map.put("code",code);
		sysBaseFloorService.deleteFloor(map);
		addMessage(redirectAttributes, "删除成功");
		return "redirect:getFloorList";
	}
    
	public SysBaseRegionService getSysBaseRegionService() {
		return sysBaseRegionService;
	}
	public void setSysBaseRegionService(SysBaseRegionService sysBaseRegionService ) {
		this.sysBaseRegionService = sysBaseRegionService;
	}
	public SysBaseShopService getSysBaseShopService() {
		return sysBaseShopService;
	}
	public void setSysBaseShopService(SysBaseShopService sysBaseShopService) {
		this.sysBaseShopService = sysBaseShopService;
	}
	public SysBaseFloorService getSysBaseFloorService() {
		return sysBaseFloorService;
	}
	public void setSysBaseFloorService(SysBaseFloorService sysBaseFloorService) {
		this.sysBaseFloorService = sysBaseFloorService;
	}
}
